package presentacio;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.TitledBorder;

public final class BorderDemo {

    private JFrame jfSdi;
    private JPanel jpMainPanel;
    ff();

    public BorderDemo() {
        this.initComponents();
        this.jfSdi.add(jfSdi);
    }

    private void initComponents() {
        this.jfSdi = new JFrame();
        this.jfSdi.setSize(600, 600);
        this.jfSdi.setResizable(true);
        this.jfSdi.setLocationRelativeTo(null);
        this.jfSdi.setTitle("Border Demo");
        this.jfSdi.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        this.jpMainPanel = new JPanel();
        this.jpMainPanel.setLayout(new GridLayout(6, 2, 3, 3));

        JPanel jpPanel = new JPanel();
        jpPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
        jpPanel.add(new JLabel("RAISED BevelBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); // Factory
        jpPanel.add(new JLabel("LOWERED BevelBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new LineBorder(Color.BLUE, 5));
        jpPanel.add(new JLabel("LineBorder, thickness = 5"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
        jpPanel.add(new JLabel("EmptyBorder with insets of 10"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new EtchedBorder(EtchedBorder.RAISED));
        jpPanel.add(new JLabel("RAISED EtchedBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
        jpPanel.add(new JLabel("LOWERED EtchedBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED));
        jpPanel.add(new JLabel("RAISED SoftBevelBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
        jpPanel.add(new JLabel("LOWERED SoftBevelBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new MatteBorder(new ImageIcon(this.getClass().getResource("/imatges/red.png"))));
        jpPanel.add(new JLabel("MatteBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new TitledBorder(new MatteBorder(new ImageIcon(this.getClass().getResource("/imatges/blue.png"))), "Title String"));
        jpPanel.add(new JLabel("TitledBorder using MatteBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new TitledBorder(new LineBorder(Color.BLACK, 5), "Title String"));
        jpPanel.add(new JLabel("TitledBorder using LineBorder"));
        this.jpMainPanel.add(jpPanel);

        jpPanel = new JPanel();
        jpPanel.setBorder(new TitledBorder(new EmptyBorder(10, 10, 10, 10), "Title String"));
        jpPanel.add(new JLabel("TitledBorder using EmptyBorder"));
        this.jpMainPanel.add(jpPanel);

        this.jfSdi.add(jpMainPanel);
        this.jfSdi.setVisible(true);
    }

    public static void main(String args[]) {
        new BorderDemo();
    }
}
